//
//  BaseCacheManager+UserDefaults.m
//  Project
//
//  Created by Suny on 14-8-11.
//  Copyright (c) 2014年 Suny. All rights reserved.
//

#import "BaseCacheManager+UserDefaults.h"

@implementation BaseCacheManager (UserDefaults)

- (BOOL)hasObjectInUserDefaultsForKey:(id)key
{
	id value = [[NSUserDefaults standardUserDefaults] objectForKey:key];
	return value ? YES : NO;
}
+ (BOOL)hasObjectInUserDefaultsForKey:(id)key
{
    id value = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    return value ? YES : NO;
}

- (id)objectInUserDefaultsForKey:(NSString *)key
{
	if ( nil == key )
		return nil;
	
	id value = [[NSUserDefaults standardUserDefaults] objectForKey:key];
	return value;
}
+ (id)objectInUserDefaultsForKey:(NSString *)key
{
    if ( nil == key )
        return nil;

    id value = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    return value;
}

- (void)setInUserDefaultsObject:(id)value forKey:(NSString *)key
{
	if ( nil == key || nil == value )
		return;
	
	[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)setInUserDefaultsObject:(id)value forKey:(NSString *)key
{
    if ( nil == key || nil == value )
        return;

    [[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)removeObjectInUserDefaultsForKey:(NSString *)key
{
	if ( nil == key )
		return;
	
	[[NSUserDefaults standardUserDefaults] removeObjectForKey:key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)removeAllObjectsInUserDefaults
{
	[NSUserDefaults resetStandardUserDefaults];
}
+ (void)removeAllObjectsInUserDefaults
{
    [NSUserDefaults resetStandardUserDefaults];
}

@end
